class Solution:
    def maxProduct(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        max_ = nums[0]
        #  当前连续最大值
        min_ = nums[0]
        #  当前连续最小值
        res = nums[0]
        for i in range(1, len(nums)):
            pre = max_
            max_ = max(max(nums[i]*pre, nums[i]), min_*nums[i])
            min_ = min(min(nums[i]*min_, nums[i]), pre*nums[i])
            res = max(res, max_)
        return res

